package com.example.demo.service.impl;

import com.example.demo.Dao.RequestLogRepository;
import com.example.demo.Entity.RequestLogExt;
import com.example.demo.Entity.WEntityVO;
import com.example.demo.Exception.JacksonException;
import com.example.demo.service.DemoService;
import com.example.demo.zhoushengwen.exceptionHandling.CustomException;
import com.example.demo.zhoushengwen.response.CommonCode;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service;

@ComponentScan(basePackages = "com.example.demo")
@Service
@Slf4j
public class DemoServiceImpl implements DemoService
{
    @Autowired
    private ApplicationContext applicationContext;
    
    @Autowired
    private RequestLogRepository requestLogRepository;
    
    @Override
    public WEntityVO insert(WEntityVO wEntityVO)
    {
        // TODO Auto-generated method stub
        log.info("这里加模拟插入", wEntityVO);
        if ("11".equals(wEntityVO.getMd5()))
            Integer.valueOf(wEntityVO.getFileid());
        if ("21".equals(wEntityVO.getMd5()))
            throw new CustomException(CommonCode.other_error);
        if ("31".equals(wEntityVO.getMd5()))
        {
            throw new JacksonException("抛自定义异常");
        }
        DemoService testService = applicationContext.getBean(DemoService.class);
        testService.insert1(wEntityVO);
        return wEntityVO;
    }
    
    @Override
    public WEntityVO insert1(WEntityVO wEntityVO)
    {
        // TODO Auto-generated method stub
        log.info("这里加模拟插入", wEntityVO);
        if ("111".equals(wEntityVO.getMd5()))
            Integer.valueOf(wEntityVO.getFileid());
        if ("211".equals(wEntityVO.getMd5()))
            throw new CustomException(CommonCode.other_error);
        if ("311".equals(wEntityVO.getMd5()))
        {
            throw new JacksonException("抛自定义异常");
        }
        return wEntityVO;
    }
}
